package org.cytoscape.myapp.cytoscape_app_v1.internal.metrics;

import java.util.List;

import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.domain.TrustedRelationship;
import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.domain.UserPositionMapping;
import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.measure.SocialCentrality;
import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.measure.SocialInfluence;
import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.measure.SocialSimilarity;
import org.cytoscape.myapp.cytoscape_app_v1.internal.metrics.measure.StructuralCohesion;
import org.cytoscape.myapp.cytoscape_app_v1.internal.model.NetworkSettings;

public class Facade {
	
	private UserPositionMapping mapping;
	private List<TrustedRelationship> trustedRelationships;

	
	public Facade(UserPositionMapping mapping,
			List<TrustedRelationship> trustedRelationships) {
		super();
		this.mapping = mapping;
		this.trustedRelationships = trustedRelationships;
	}
	
	public UserPositionMapping getMapping() {
		return mapping;
	}

	public void setMapping(UserPositionMapping mapping) {
		this.mapping = mapping;
	}

	public List<TrustedRelationship> getTrustedRelationships() {
		return trustedRelationships;
	}

	public void setTrustedRelationships(
			List<TrustedRelationship> trustedRelationships) {
		this.trustedRelationships = trustedRelationships;
	}



	public double[][] getCohesion(){
		
		StructuralCohesion cohesion = new StructuralCohesion(mapping,trustedRelationships);
		return cohesion.getStCMatrix();
	}
	
	public double[] getCentrality(){
	
		SocialCentrality centrality = new SocialCentrality(this.mapping);
		return centrality.getSCVector();
	}
	
	
	public double[][] getInfluence(){
	
		SocialInfluence influence = new SocialInfluence(mapping, trustedRelationships);
		return influence.getSIMatrix();
	}
	
	public double[][] getSimilarity(){
		
		SocialSimilarity similarity = new SocialSimilarity(mapping);
		return similarity.getSSMatrix();
	}
	
	public double[][] getDistancesByAttribute(String attribute){
		
		double[][] distance = null;
		
		if (attribute.equals(NetworkSettings.selectVisualOption[0])){
			distance = this.getCohesion();
		}
		
		if (attribute.equals(NetworkSettings.selectVisualOption[1])){
			distance = this.getInfluence();
		}

		if (attribute.equals(NetworkSettings.selectVisualOption[2])){
			distance = this.getSimilarity();
		}
		
		return distance;
	}

}
